const MAX_WIDTH = 1920
const MAX_HEIGHT = 1080
/* eslint-disable */
/**
 * 拉伸
 * @param sel
 * @param ww
 * @param hh
 */
export function resize(sel, ww, hh) {
  const el = document.querySelector(sel);
  const bw = document.body.clientWidth
  const bh = document.body.clientHeight

  ww = ww || MAX_WIDTH
  hh = hh || MAX_HEIGHT

  let per = bw / ww

  let pery = bh / hh

  // if(hh * per > bh) {
  //   pery = bh / hh
  //   per = pery
  // }

  el.style.transform = 'scaleX(' + per + ') scaleY(' + pery + ') translateX(-50%) translateY(-50%)'

}

/**
 * 压缩固定宽高
 * @param sel
 * @param ww
 * @param hh
 */
export function resizeStatic(sel, ww, hh) {
  const el = document.querySelector(sel);
  const bw = document.body.clientWidth
  const bh = document.body.clientHeight

  ww = ww || MAX_WIDTH
  hh = hh || MAX_HEIGHT

  let per = bw / ww

  let pery = bh / hh
  if(hh * per > bh) {
    pery = bh / hh
    per = pery
  }
  el.style.transform = 'scaleX(' + per + ') scaleY(' + pery + ') translateX(-50%) translateY(-50%)'
}

